package yang.VirtualMachine.chapter11.asmTime;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public class TimeStatClassAdater extends ClassVisitor {

	public TimeStatClassAdater(ClassVisitor cv) {
		super(Opcodes.ASM5, cv);
	}
	
	@Override
	public MethodVisitor visitMethod(int access, String name, String desc,
            String signature, String[] exceptions) {
		MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
		MethodVisitor wrappedMv = mv;
		if (wrappedMv != null) {
			if ("operation".equals(name)) {
				wrappedMv = new TimeStatMethodAdater(mv);
			}
		}
		
		return wrappedMv;
	}

}
